<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
session_start();
class checkout extends CI_Controller {
	
	protected  $language = 0;

	public function __construct()
	{
		parent::__construct();
		$this->load->library('parser');
		$this->load->helper('form');
		$this->load->helper(array('form', 'url'));
		$this->load->helper('language');
		$this->load->helper('html');
		$this->load->library('encrypt');
		$this->load->helper('url');
		$this->load->library('image_lib');
		$this->load->library('session');
		$this->load->library('zip');
		$this->load->library('unzip');
		$this->load->helper('url');
		$this->load->helper('xml');
	}
	
	public function addtocart($productid=0)
	{
		$data = array();
		if(isset($_SESSION['custkey']))
		{
			$custid = $_SESSION['custkey'];
			$this->load->model('customer_model');
			$data['customername'] = $this->customer_model->getcustomerbyid($custid);
		}		
		
		$this->load->view('template/header',$data);
		$this->load->view('template/adventive',$data);
		$this->load->view('template/search',$data);
 
		$this->load->model('order_model');
		
		$this->load->view('template/potsnews',$data);
		
		$this->load->model('news_model');
		$data['cateshow']=$this->news_model->cateshow(0);
		$data['catehide']=$this->news_model->catehide(0);
		$data['banner']=$this->news_model->banner();
		$data['newhot']=$this->news_model->newhot();
		$this->load->view('template/menuhome',$data);
		$this->load->view('template/homecontentleft',$data);
		
		$productinfo=$this->news_model->getproductinfo($productid);
		$catename="";
		$phone="";
		$productname="";
		$price="";
		$unit="";
		$like="";
		$imgpath="";
		$content="";
		foreach($productinfo as $row){
			$catename=$row->catename;
			$phone=$row->phone;
			$productname=$row->productname;
			$price=$row->price;
			$unit=$row->unit;
			$like=$row->like;
			$imgpath=$row->imgpath;
			$content=$row->content;
		}
		$data['catename']=$catename;
		$data['phone']=$phone;
		$data['productname']=$productname;
		$data['price']=$price;
		$data['unit']=$unit;
		$data['like']=$like;
		$data['imgpath']=$imgpath;
		$data['content']=$content;
	
		$this->order_model->addusercard($_SESSION['custkey'],$productid);
		$allcart = $this->order_model->getcart($_SESSION['custkey']);
		foreach($allcart as $row)
		{
			//hiển thị thông tin sản phẩm, một loạt sản phẩm theo customer key
		}		
		$data['producthot']=$this->news_model->producthot();
		$this->load->view('fronend/cart',$data);
		
		
		
		
		$this->load->view('template/closediv');
		$data['newsshowtable']=$this->news_model->roomhot(1);
		$data['newshidetable']=$this->news_model->roomhot(0);
		$this->load->view('template/homecontentmenuright',$data);	
		$this->load->view('template/closediv');	
		$this->parser->parse('template/footer', $data,false);
	}
	
}
